/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.androidhorizonscrollview;

import android.app.Activity;

import android.os.Bundle;
import android.os.CountDownTimer;

import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.widget.HorizontalScrollView;

/**
 *\
 * @author LaptopFernandes01
 */
public class MainActivity extends Activity {

    private HorizontalScrollView ScrollOne;
    private HorizontalScrollView ScrollTwo;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        ScrollOne = (HorizontalScrollView)this.findViewById(R.id.scrollone);
        ScrollTwo = (HorizontalScrollView)this.findViewById(R.id.scrolltwo);
        ScrollOne.setHorizontalScrollBarEnabled(false);
        ScrollTwo.setHorizontalScrollBarEnabled(false);

        ScrollOne.setOnTouchListener(scrollOneListener);
        ScrollTwo.setOnTouchListener(scrollTwoListener);

    }
 
 private OnTouchListener scrollOneListener = new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent e) {

         new CountDownTimer(2000, 20) {

        public void onTick(long millisUntilFinished) {
                ScrollTwo.scrollTo(ScrollOne.getScrollX(), 0);
        }

        public void onFinish() {

        }
     }.start();


                return false;
            }
        };

 private OnTouchListener scrollTwoListener = new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent e) {

             new CountDownTimer(2000, 20) {

                    public void onTick(long millisUntilFinished) {
                            ScrollOne.scrollTo(ScrollTwo.getScrollX(), 0);
                    }

                    public void onFinish() {

                    }
             }.start();


                return false;
            }
        };



}